The present invention relates to three-dimensional graphics processing, and in particular to a method and system for efficient rendering of image component polygons.
In computer graphics, the surfaces of 3-D objects are approximated using polygons (typically triangles). Using smaller polygons creates more realistic 3-D objects on the computer screens. However, using smaller polygons requires a larger number of polygons to represent an object.
Surfaces of objects and the polygons representing the surfaces are provided in a three dimensional coordinate system, typically referred to as xe2x80x9cobject spacexe2x80x9d O(x, y, z). However, graphical displays used with computers and consumer video equipment are only two-dimensional. Therefore, an image of the objects is displayed on a graphical display by projecting the object onto a two-dimensional coordinate system, typically referred to as xe2x80x9cscreen spacexe2x80x9d S(x, y).
Generally, a polygon can be described by the polygon""s vertices. Typically the description of a vertex includes the coordinates of the vertex in object space, i.e. (x, y, z); perspective projection parameters (w, s, t); the color of the vertex, typically using color space coordinates (r, g, b); an alpha parameter; and a fog parameter. The vertex information is processed through well known setup processes into a parameter list suitable for a 3-D pipeline. The exact parameter list format depends on the 3-D pipeline used.
The 3-D pipeline performs rasterization of the polygons, i.e. the conversion of polygons into pixels in screen space. A common rasterization algorithm for polygons includes four major steps: walk edges, walk spans, compute texture coordinates, and compute fog value. Many elements of the theory and techniques of rasterization are known to those skilled in the art.
Texturing pixels is a technique for mapping an image (xe2x80x9ctexturexe2x80x9d) onto the polygonal surfaces of a computer-generated object, so as to allow the object to appear more realistic in a displayed scene. Texture mapping allows a texture to be superimposed onto each polygon of an object, using transformation techniques that compensate the appearance of the texture in each polygon for lighting conditions, angles of viewing and other conditions which may affect the appearance of the object. Many elements of the theory and techniques of texture mapping are known to those skilled in the art.
As screen space pixels are generated by rasterization, the screen space pixels are blended in a blender or back end processor to create 2-D images suitable for graphic displays. Specifically, the blender or back end processor performs Z-buffering and alpha blending on the screen space pixels. Z-buffering determines which screen space pixels can be seen on the graphics screen. Specifically, Z-buffering compares the z-coordinate of each screen space pixel against the z-coordinate of the screen space pixel with the same x- and y-coordinates already in the frame buffer. If the screen space pixel is in front of the frame buffer pixel, the parameters of the screen space pixel is stored in the frame buffer; otherwise the contents of the frame buffer remain unchanged. The frame buffer is typically addressed by mapping the x- and y-coordinates of a pixel into a memory address. The frame buffer stores parameters regarding the pixel such as color space values and the z-coordinate. Alpha blending controls the translucence of overlaid surfaces. The screen space pixels are stored in a frame buffer for displaying on a graphics display. Many elements of the theory and techniques of Z-buffering and alpha blending are known to those skilled in the art.
For realistic 3-D graphics, a 3-D image may include thousands of polygons for real-time applications or even millions of polygons for high-resolution 3-D images. Since many calculations are required to render each polygon, a high-quality image can consume a large amount of processor time. Thus, performance and image quality are often competing considerations due to the limited processing speeds available. Any decrease in the processing time required to render an image component polygon is desirable, since it enables either higher-quality graphics to be produced at a given frame rate or faster rendering of a given image.
Therefore, a need has arisen for a three-dimensional graphics processing system and method that address the disadvantages and deficiencies of the prior art. In particular, a need has arisen for a three-dimensional graphics processing system and method capable of efficient rasterization of an image component polygon.
Accordingly, a method for displaying an image component polygon is disclosed. In one embodiment, the method includes receiving information indicating the location of the perimeter of the image component polygon, selecting a current pixel span with a plurality of pixels, selecting a current scan direction for the current pixel span, storing a location to begin scanning the subsequent pixel span, scanning at least one pixel in the current pixel span in the current scan direction to determine whether the pixel is within the image component polygon, determining image values for each pixel in the current pixel span in the current scan direction that is within the image component polygon, storing the image values in a frame buffer for display, and scanning the subsequent pixel span from the stored location after each pixel in the current pixel span has been scanned.
In another embodiment of the present invention, a graphics processing system includes an initial processing system that receives a command to render an image component polygon and generates parameters for calculating image values for the image component polygon. The system also includes a backtrack register capable of storing a pixel location. A rasterization engine scans a pixel span in a selected direction and determines whether the pixel span is to be scanned in a direction opposite the selected direction. The rasterization engine stores a backtrack location in the backtrack register in response to a determination that the pixel span is to be scanned in a direction opposite the selected direction, and stores a location to begin scanning a subsequent pixel span in the backtrack register in response to a determination that a backtrack location is not stored in the backtrack register. The rasterization engine also calculates image values for each pixel in the pixel span in the current scan direction. A pixel data processing system receives the image values from the rasterization engine and stores the image values in a frame buffer for display.
An advantage of the present invention is that the rasterization method described herein provides an efficient process for determining which pixels are within an image component polygon, and for calculating interpolant values for those pixels which are within the image component polygon. Another advantage of the present invention is that the method reduces the amount of scanning of pixels outside the image component polygon, thereby reducing image rendering time. Yet another advantage is that, by using an existing register, the method increases image rendering speed without a corresponding increase in the number of logic gates or the amount of chip area required for the rasterization engine.